<!-- 设置弹窗 -->

<template>
  <EasyModal v-model="model" title="设置" small @submit="toSubmit">
    <MajorTitle title="自动加入黑名单设置" />

    <WebForm path="setting" :one="info" class="row2">
      <FormNum bind="month" :min="1" :max="60" rightBtn noLabel fifth required @change="toChange('month')" />
      <FormSlot :labelWidth="10" auto>个月内，违规次数大于等于</FormSlot>
      <FormNum :labelWidth="10" bind="count" :min="1" :max="100" rightBtn fifth required @change="toChange('count')" />
      <FormSlot :labelWidth="10" auto>次</FormSlot>
    </WebForm>
  </EasyModal>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'SettingModal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixScreen('setting')],

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 显示弹窗 (双向绑定)
     */
    model: {
      get() {
        return this.infoVisible
      },
      set() {
        this.closeInfo()
      },
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 点击提交
     */
    async toSubmit() {
      await this.refForm.check()
      this.startEdit()
    },

    /**
     * 数据更新
     */
    toChange(key) {
      const matched = this.info.content.find((item) => item.key === key)
      if (matched) matched.value = this.info[key] ? `${this.info[key]}` : ''
    },
  },
}
</script>
